package cn.mymall;

import cn.mymall.web.interceptor.MemberHomeInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@SpringBootApplication
@EnableScheduling
@MapperScan(basePackages={"cn.mymall.mapper"})
public class Application implements WebMvcConfigurer {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Bean
    MemberHomeInterceptor getApiuserInterceptor() {
        return new MemberHomeInterceptor();
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getApiuserInterceptor())
                .addPathPatterns("/home/**")
                .excludePathPatterns("/static/**");
    }
}
